package edu.udel.libra.model.repository;

import java.util.ArrayList;
import java.util.List;

import javax.sql.DataSource;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import edu.udel.libra.model.Player;

public class JdbcPlayerRepository implements PlayerRepository 
{
	private JdbcTemplate jdbcTemplate;
	private List<Player> players;
	
	public JdbcPlayerRepository() {
		// TODO: Add database connection
		
		// Sample data
		players = new ArrayList<Player>();
		
		Player player1 = new Player();
		player1.setId(0);
		player1.setName("Dyrus");
		
		Player player2 = new Player();
		player2.setId(1);
		player2.setName("Scarra");
		
		players.add(player1);
		players.add(player2);
		// endof Sample data
	}
	
	public JdbcPlayerRepository(DataSource dataSource) {
		jdbcTemplate = new JdbcTemplate(dataSource);
	}

	@Override
	public List<Player> getPlayers() {
		return players;
	}

	@Override
	public Player getPlayer(long id) {
		return players.get((int) id);
	}

	@Override
	public List<Player> getPlayersForLeague(long leagueId) {
		return players;
	}

	@Override
	public List<Player> getPlayersForTeam(long teamId, long leagueId) {
		return players;
	}

}
